package com.study.example.thread;

import sun.nio.ch.ThreadPool;

import java.util.concurrent.*;

public class ThreadDemo01 {

    public static void main(String[] args) {
        //
        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getName());
            }
        },"测试线程").start();

        //02 实现runable接口

        //03 callable
        FutureTask futureTask = new FutureTask(new MyCallable());
        try {
            System.out.println(futureTask.get());
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }

        //04 线程池
//        ThreadPoolExecutor threadPool = new ThreadPoolExecutor();

    }


    private class MyThread extends Thread{
        @Override
        public void run(){
            System.out.println(Thread.currentThread().getName());
        }
    }

    private class MyThread02 implements Runnable{

        @Override
        public void run() {
            System.out.println(Thread.currentThread().getName());
        }
    }

    private static class MyCallable implements Callable{

        @Override
        public Object call() throws Exception {
            return Thread.currentThread().getName();
        }

    }




}
